package com.easyidea.its.util.excel;

/*============================================================
 * $Id: $
 * $Revision: $
 * $Date: $ by $Author: $
 * ===========================================================
 * 
 * Copyright (c) 2006~2007 Infowarelab Co.,LTD. 
 * All rights reserved.
 * 
 * Please refer to the License for the detailed infomation
 *============================================================*/


import java.util.Collection;

/**
 * @author wener.hu
 * @date 2007-5-24
 *
 */
public class SheetDefinition {
	
	/**
	 * If true will ignore first row.
	 */
	private boolean hasTitle;
	
	/**
	 * Parse the Excel data to this class entity,need construct without parameters.
	 */
	private Class entityClass;
	
	/**
	 * Define the fields from first column to by turns. You can set null or empty string if needn't process some one column.
	 */
	private String[] colArray  = null;
	
	/**
	 * Define the Excel Title for every Column. If length not equals colArray.length(), will be igorned.
	 */
	private String[] titleArray = null;
	
	private String sheetName;
	
	private Collection rowEntitys;
	
	/**
	 * 构造一个读出的Sheet.
	 * @param hasTitle
	 * @param colArray
	 * @param entityClass
	 */
	public SheetDefinition(boolean hasTitle, String[] colArray, Class entityClass) {
		super();
		this.hasTitle = hasTitle;
		this.colArray = colArray;
		this.entityClass = entityClass;
	}
	
	/**
	 * 构造一个写入的Sheet.
	 * @param rowEntitys
	 * @param colArray
	 * @param titles
	 */
	public SheetDefinition(String sheetName, Collection rowEntitys, String[] colArray, String[] titles) {
		super();
		this.sheetName = sheetName;
		this.rowEntitys = rowEntitys;
		this.colArray = colArray;
		if (titles != null && titles.length == colArray.length )
			this.titleArray = titles;
	}

	public String[] getColArray() {
		return colArray;
	}

	public Class getEntityClass() {
		return entityClass;
	}

	public boolean isHasTitle() {
		return hasTitle;
	}
	
	public int getColSize() {
		return colArray.length;
	}

	public String[] getTitleArray() {
		return titleArray;
	}

	public void setTitleArray(String[] titleArray) {
		if (titleArray != null && titleArray.length == colArray.length )
			this.titleArray = titleArray;
	}

	public Collection getRowEntitys() {
		return rowEntitys;
	}

	public void setRowEntitys(Collection rowEntitys) {
		this.rowEntitys = rowEntitys;
	}

	public String getSheetName() {
		return sheetName;
	}

	public void setSheetName(String sheetName) {
		this.sheetName = sheetName;
	}

}
